<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>EasyRTC Documentation</title>
  <script src="scripts/prettify/prettify.js"> </script>
  <script src="scripts/prettify/lang-css.js"> </script>
  <!--[if lt IE 9]>
    <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  <![endif]-->
  <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
  <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
  <link href="../assets/easyrtc-docs-jsdoc-styles-1.css" media="all" rel="stylesheet" />
</head>
<body>
<header class="template">
	<div class="wrapper-content">
    <a href="../index.html"><img src="../assets/easyrtc-logo.png" alt="EasyRTC Documentation"></a>
		<h1 title="EasyRTC Documentation">Documentation</h1>
	</div>
</header>
<div class="wrapper-docs">
<nav>
	<h2><a href="../index.html">Docs Home</a></h2>
	<h3>EasyRTC Guides</h3>
	<ul>
		<li><a href="../easyrtc_faq.html">FAQ</a></li>
		<li><a href="../easyrtc_gettingStarted.html">Getting Started</a></li>
		<li><a href="../easyrtc_server_install.html">EasyRTC Server: Installation</a></li>
		<li><a href="../easyrtc_client_tutorial.html">EasyRTC Framework Tutorial</a></li>
		<li><a href="../easyrtc_rooms.html">Rooms</a></li>
		<li><a href="../easyrtc_server_configuration.html">EasyRTC Server: Configuration</a></li>
		<li><a href="../easyrtc_server_events.html">EasyRTC Server: Events</a></li>
		<li><a href="../easyrtc_server_ice.html">EasyRTC Server: ICE Configuration</a></li>
		<li><a href="../easyrtc_with_other_servers.html">Using Alongside Other Servers</a></li>
		<li><a href="../easyrtc_server_ssl.html">EasyRTC Server: Using SSL</a></li>
		<li><a href="../easyrtc_webrtc_problems.html">WebRTC Problems and Possible Fixes</a></li>
		<li><a href="../easyrtc_upcoming_features.html">Upcoming Features</a></li>
		<li><a href="../easyrtc_changelog.html">Change Log</a></li>
	</ul>
	<h3>EasyRTC Client Classes</h3>
	<ul>
		<li><a href="../client-api/Easyrtc.html">Easyrtc</a></li>
		<li><a href="../client-api/Easyrtc_App.html">Easyrtc_App</a></li>
		<li><a href="../client-api/Easyrtc_ft.html">Easyrtc_ft</a></li>
		<li><a href="../client-api/Easyrtc_IframeCapture.html">Easyrtc_IframeCapture</a></li>
		<li><a href="../client-api/Easyrtc_No_IframeCapture.html">Easyrtc_No_IframeCapture</a></li>
		<li><a href="../client-api/Easyrtc_Rates.html">Easyrtc_Rates</a></li>
		<li><a href="../client-api/Easyrtc_Recorder.html">Easyrtc_Recorder</a></li>
	</ul>
	<h3>EasyRTC Server Modules</h3>
	<ul>
		<li><a href="../server-api/module-easyrtc_default_event_listeners.html">easyrtc_default_event_listeners</a></li>
		<li><a href="../server-api/module-easyrtc_default_options.html">easyrtc_default_options</a></li>
		<li><a href="../server-api/module-easyrtc_private_obj.html">easyrtc_private_obj</a></li>
		<li><a href="../server-api/module-easyrtc_public_obj.html">easyrtc_public_obj</a></li>
		<li><a href="../server-api/module-easyrtc_util.html">easyrtc_util</a></li>
		<li><a href="../server-api/module-general_util.html">general_util</a></li>
	</ul>
	<h3>EasyRTC Server Classes</h3>
	<ul>
		<li><a href="../server-api/module-easyrtc_default_event_listeners-eventListener.html">eventListener</a></li>
		<li><a href="../server-api/module-easyrtc_public_obj-pub.html">pub</a></li>
		<li><a href="../server-api/module-easyrtc_public_obj-pub.events.html">events</a></li>
		<li><a href="../server-api/module-easyrtc_public_obj-pub.util.html">util</a></li>
		<li><a href="../server-api/module-easyrtc_util-eu.html">eu</a></li>
		<li><a href="../server-api/module-general_util-g.html">g</a></li>
		<li><a href="../server-api/pub.appObj.html">appObj</a></li>
		<li><a href="../server-api/pub.appObj.connectionObj.html">connectionObj</a></li>
		<li><a href="../server-api/pub.appObj.connectionObj.connectionRoomObj.html">connectionRoomObj</a></li>
		<li><a href="../server-api/pub.appObj.roomObj.html">roomObj</a></li>
		<li><a href="../server-api/pub.appObj.sessionObj.html">sessionObj</a></li>
	</ul>
</nav>
<div class="easyrtc-docs-content">
<div id="main">
<h1 class="page-title">Source: easyrtc_util.js</h1>
<section>
<article>
<pre class="prettyprint source linenums easyrtc"><code><a name="line1"></a><div class="linenumber">1</div><div style="width:0em;display:inline-block"></div>/*&nbsp;global&nbsp;module,&nbsp;require&nbsp;*/
<a name="line2"></a><div class="linenumber">2</div><div style="width:0em;display:inline-block"></div>
<a name="line3"></a><div class="linenumber">3</div><div style="width:0em;display:inline-block"></div>/**
<a name="line4"></a><div class="linenumber">4</div><div style="width:0em;display:inline-block"></div>*&nbsp;Utility&nbsp;functions&nbsp;specific&nbsp;to&nbsp;EasyRTC.
<a name="line5"></a><div class="linenumber">5</div><div style="width:0em;display:inline-block"></div>*
<a name="line6"></a><div class="linenumber">6</div><div style="width:0em;display:inline-block"></div>*&nbsp;@module&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;easyrtc_util
<a name="line7"></a><div class="linenumber">7</div><div style="width:0em;display:inline-block"></div>*&nbsp;@author&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Priologic&nbsp;Software,&nbsp;info@easyrtc.com
<a name="line8"></a><div class="linenumber">8</div><div style="width:0em;display:inline-block"></div>*&nbsp;@copyright&nbsp;&nbsp;&nbsp;Copyright&nbsp;2016&nbsp;Priologic&nbsp;Software.&nbsp;All&nbsp;rights&nbsp;reserved.
<a name="line9"></a><div class="linenumber">9</div><div style="width:0em;display:inline-block"></div>*&nbsp;@license&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;BSD&nbsp;v2,&nbsp;see&nbsp;LICENSE&nbsp;file&nbsp;in&nbsp;module&nbsp;root&nbsp;folder.
<a name="line10"></a><div class="linenumber">10</div><div style="width:0em;display:inline-block"></div>*/
<a name="line11"></a><div class="linenumber">11</div><div style="width:0em;display:inline-block"></div>
<a name="line12"></a><div class="linenumber">12</div><div style="width:0em;display:inline-block"></div>var&nbsp;util&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;require("util");
<a name="line13"></a><div class="linenumber">13</div><div style="width:0em;display:inline-block"></div>var&nbsp;_&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;require("underscore");&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;General&nbsp;utility&nbsp;functions&nbsp;external&nbsp;module
<a name="line14"></a><div class="linenumber">14</div><div style="width:0em;display:inline-block"></div>var&nbsp;g&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;require("./general_util");&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;General&nbsp;utility&nbsp;functions&nbsp;local&nbsp;module
<a name="line15"></a><div class="linenumber">15</div><div style="width:0em;display:inline-block"></div>var&nbsp;e&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;require("./easyrtc_private_obj");&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;EasyRTC&nbsp;private&nbsp;object
<a name="line16"></a><div class="linenumber">16</div><div style="width:0em;display:inline-block"></div>
<a name="line17"></a><div class="linenumber">17</div><div style="width:0em;display:inline-block"></div>/**
<a name="line18"></a><div class="linenumber">18</div><div style="width:0em;display:inline-block"></div>*&nbsp;&nbsp;Object&nbsp;to&nbsp;hold&nbsp;EasyRTC&nbsp;Utility&nbsp;methods&nbsp;and&nbsp;classes.
<a name="line19"></a><div class="linenumber">19</div><div style="width:0em;display:inline-block"></div>*
<a name="line20"></a><div class="linenumber">20</div><div style="width:0em;display:inline-block"></div>*&nbsp;@class
<a name="line21"></a><div class="linenumber">21</div><div style="width:0em;display:inline-block"></div>*/
<a name="line22"></a><div class="linenumber">22</div><div style="width:0em;display:inline-block"></div>var&nbsp;eu&nbsp;=&nbsp;module.exports;
<a name="line23"></a><div class="linenumber">23</div><div style="width:0em;display:inline-block"></div>
<a name="line24"></a><div class="linenumber">24</div><div style="width:0em;display:inline-block"></div>/**
<a name="line25"></a><div class="linenumber">25</div><div style="width:0em;display:inline-block"></div>*&nbsp;Disconnects&nbsp;socket.&nbsp;Failure&nbsp;results&nbsp;in&nbsp;a&nbsp;debug&nbsp;level&nbsp;log&nbsp;message.
<a name="line26"></a><div class="linenumber">26</div><div style="width:0em;display:inline-block"></div>*
<a name="line27"></a><div class="linenumber">27</div><div style="width:0em;display:inline-block"></div>*&nbsp;@param&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{Object}&nbsp;socket&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Socket.io&nbsp;connection&nbsp;object.
<a name="line28"></a><div class="linenumber">28</div><div style="width:0em;display:inline-block"></div>*/
<a name="line29"></a><div class="linenumber">29</div><div style="width:0em;display:inline-block"></div>eu.socketDisconnect&nbsp;=&nbsp;function(socket)&nbsp;{
<a name="line30"></a><div class="linenumber">30</div><div style="width:2em;display:inline-block"></div>try&nbsp;{
<a name="line31"></a><div class="linenumber">31</div><div style="width:4em;display:inline-block"></div>socket.disconnect();
<a name="line32"></a><div class="linenumber">32</div><div style="width:2em;display:inline-block"></div>}&nbsp;catch(err)&nbsp;{
<a name="line33"></a><div class="linenumber">33</div><div style="width:4em;display:inline-block"></div>eu.log("debug",&nbsp;"Socket&nbsp;disconnection&nbsp;command&nbsp;failed.&nbsp;Socket&nbsp;may&nbsp;already&nbsp;be&nbsp;disconnected.");
<a name="line34"></a><div class="linenumber">34</div><div style="width:2em;display:inline-block"></div>}
<a name="line35"></a><div class="linenumber">35</div><div style="width:0em;display:inline-block"></div>};
<a name="line36"></a><div class="linenumber">36</div><div style="width:0em;display:inline-block"></div>
<a name="line37"></a><div class="linenumber">37</div><div style="width:0em;display:inline-block"></div>
<a name="line38"></a><div class="linenumber">38</div><div style="width:0em;display:inline-block"></div>/**
<a name="line39"></a><div class="linenumber">39</div><div style="width:0em;display:inline-block"></div>*&nbsp;Custom&nbsp;Error&nbsp;Object&nbsp;for&nbsp;EasyRTC&nbsp;Server&nbsp;Errors.
<a name="line40"></a><div class="linenumber">40</div><div style="width:0em;display:inline-block"></div>*
<a name="line41"></a><div class="linenumber">41</div><div style="width:0em;display:inline-block"></div>*&nbsp;@extends&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Error
<a name="line42"></a><div class="linenumber">42</div><div style="width:0em;display:inline-block"></div>*&nbsp;@param&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{string}&nbsp;msg&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Text&nbsp;message&nbsp;describing&nbsp;the&nbsp;error.
<a name="line43"></a><div class="linenumber">43</div><div style="width:0em;display:inline-block"></div>*&nbsp;@returns&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{Error}
<a name="line44"></a><div class="linenumber">44</div><div style="width:0em;display:inline-block"></div>*/
<a name="line45"></a><div class="linenumber">45</div><div style="width:0em;display:inline-block"></div>eu.ServerError&nbsp;=&nbsp;function(msg)&nbsp;{
<a name="line46"></a><div class="linenumber">46</div><div style="width:2em;display:inline-block"></div>eu.ServerError.super_.call(this,&nbsp;msg,&nbsp;this.constructor);
<a name="line47"></a><div class="linenumber">47</div><div style="width:0em;display:inline-block"></div>};
<a name="line48"></a><div class="linenumber">48</div><div style="width:0em;display:inline-block"></div>util.inherits(eu.ServerError,&nbsp;g.AbstractError);
<a name="line49"></a><div class="linenumber">49</div><div style="width:0em;display:inline-block"></div>eu.ServerError.prototype.name&nbsp;=&nbsp;"Server&nbsp;Error";
<a name="line50"></a><div class="linenumber">50</div><div style="width:0em;display:inline-block"></div>eu.ServerError.prototype.errorLevel&nbsp;=&nbsp;"error";
<a name="line51"></a><div class="linenumber">51</div><div style="width:0em;display:inline-block"></div>
<a name="line52"></a><div class="linenumber">52</div><div style="width:0em;display:inline-block"></div>
<a name="line53"></a><div class="linenumber">53</div><div style="width:0em;display:inline-block"></div>/**
<a name="line54"></a><div class="linenumber">54</div><div style="width:0em;display:inline-block"></div>*&nbsp;Custom&nbsp;Error&nbsp;Object&nbsp;for&nbsp;EasyRTC&nbsp;Application&nbsp;Errors.
<a name="line55"></a><div class="linenumber">55</div><div style="width:0em;display:inline-block"></div>*
<a name="line56"></a><div class="linenumber">56</div><div style="width:0em;display:inline-block"></div>*&nbsp;@extends&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Error
<a name="line57"></a><div class="linenumber">57</div><div style="width:0em;display:inline-block"></div>*&nbsp;@param&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{string}&nbsp;msg&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Text&nbsp;message&nbsp;describing&nbsp;the&nbsp;error.
<a name="line58"></a><div class="linenumber">58</div><div style="width:0em;display:inline-block"></div>*&nbsp;@returns&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{Error}
<a name="line59"></a><div class="linenumber">59</div><div style="width:0em;display:inline-block"></div>*/
<a name="line60"></a><div class="linenumber">60</div><div style="width:0em;display:inline-block"></div>eu.ApplicationError&nbsp;=&nbsp;function(msg)&nbsp;{
<a name="line61"></a><div class="linenumber">61</div><div style="width:2em;display:inline-block"></div>eu.ApplicationError.super_.call(this,&nbsp;msg,&nbsp;this.constructor);
<a name="line62"></a><div class="linenumber">62</div><div style="width:0em;display:inline-block"></div>};
<a name="line63"></a><div class="linenumber">63</div><div style="width:0em;display:inline-block"></div>util.inherits(eu.ApplicationError,&nbsp;g.AbstractError);
<a name="line64"></a><div class="linenumber">64</div><div style="width:0em;display:inline-block"></div>eu.ApplicationError.prototype.name&nbsp;=&nbsp;"Application&nbsp;Error";
<a name="line65"></a><div class="linenumber">65</div><div style="width:0em;display:inline-block"></div>eu.ApplicationError.prototype.errorLevel&nbsp;=&nbsp;"error";
<a name="line66"></a><div class="linenumber">66</div><div style="width:0em;display:inline-block"></div>
<a name="line67"></a><div class="linenumber">67</div><div style="width:0em;display:inline-block"></div>
<a name="line68"></a><div class="linenumber">68</div><div style="width:0em;display:inline-block"></div>/**
<a name="line69"></a><div class="linenumber">69</div><div style="width:0em;display:inline-block"></div>*&nbsp;Custom&nbsp;Error&nbsp;Object&nbsp;for&nbsp;Connection&nbsp;Errors.
<a name="line70"></a><div class="linenumber">70</div><div style="width:0em;display:inline-block"></div>*
<a name="line71"></a><div class="linenumber">71</div><div style="width:0em;display:inline-block"></div>*&nbsp;@extends&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Error
<a name="line72"></a><div class="linenumber">72</div><div style="width:0em;display:inline-block"></div>*&nbsp;@param&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{string}&nbsp;msg&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Text&nbsp;message&nbsp;describing&nbsp;the&nbsp;error.
<a name="line73"></a><div class="linenumber">73</div><div style="width:0em;display:inline-block"></div>*&nbsp;@returns&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{Error}
<a name="line74"></a><div class="linenumber">74</div><div style="width:0em;display:inline-block"></div>*/
<a name="line75"></a><div class="linenumber">75</div><div style="width:0em;display:inline-block"></div>eu.ConnectionError&nbsp;=&nbsp;function(msg)&nbsp;{
<a name="line76"></a><div class="linenumber">76</div><div style="width:2em;display:inline-block"></div>eu.ConnectionError.super_.call(this,&nbsp;msg,&nbsp;this.constructor);
<a name="line77"></a><div class="linenumber">77</div><div style="width:0em;display:inline-block"></div>};
<a name="line78"></a><div class="linenumber">78</div><div style="width:0em;display:inline-block"></div>util.inherits(eu.ConnectionError,&nbsp;g.AbstractError);
<a name="line79"></a><div class="linenumber">79</div><div style="width:0em;display:inline-block"></div>eu.ConnectionError.prototype.name&nbsp;=&nbsp;"Connection&nbsp;Error";
<a name="line80"></a><div class="linenumber">80</div><div style="width:0em;display:inline-block"></div>eu.ConnectionError.prototype.errorLevel&nbsp;=&nbsp;"error";
<a name="line81"></a><div class="linenumber">81</div><div style="width:0em;display:inline-block"></div>
<a name="line82"></a><div class="linenumber">82</div><div style="width:0em;display:inline-block"></div>
<a name="line83"></a><div class="linenumber">83</div><div style="width:0em;display:inline-block"></div>/**
<a name="line84"></a><div class="linenumber">84</div><div style="width:0em;display:inline-block"></div>*&nbsp;Custom&nbsp;Error&nbsp;Object&nbsp;for&nbsp;EasyRTC&nbsp;Server&nbsp;Warnings.
<a name="line85"></a><div class="linenumber">85</div><div style="width:0em;display:inline-block"></div>*
<a name="line86"></a><div class="linenumber">86</div><div style="width:0em;display:inline-block"></div>*&nbsp;@extends&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Error
<a name="line87"></a><div class="linenumber">87</div><div style="width:0em;display:inline-block"></div>*&nbsp;@param&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{string}&nbsp;msg&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Text&nbsp;message&nbsp;describing&nbsp;the&nbsp;error.
<a name="line88"></a><div class="linenumber">88</div><div style="width:0em;display:inline-block"></div>*&nbsp;@returns&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{Error}
<a name="line89"></a><div class="linenumber">89</div><div style="width:0em;display:inline-block"></div>*/
<a name="line90"></a><div class="linenumber">90</div><div style="width:0em;display:inline-block"></div>eu.ServerWarning&nbsp;=&nbsp;function(msg)&nbsp;{
<a name="line91"></a><div class="linenumber">91</div><div style="width:2em;display:inline-block"></div>eu.ServerWarning.super_.call(this,&nbsp;msg,&nbsp;this.constructor);
<a name="line92"></a><div class="linenumber">92</div><div style="width:0em;display:inline-block"></div>};
<a name="line93"></a><div class="linenumber">93</div><div style="width:0em;display:inline-block"></div>util.inherits(eu.ServerWarning,&nbsp;g.AbstractError);
<a name="line94"></a><div class="linenumber">94</div><div style="width:0em;display:inline-block"></div>eu.ServerWarning.prototype.name&nbsp;=&nbsp;"Server&nbsp;Warning";
<a name="line95"></a><div class="linenumber">95</div><div style="width:0em;display:inline-block"></div>eu.ServerWarning.prototype.errorLevel&nbsp;=&nbsp;"warning";
<a name="line96"></a><div class="linenumber">96</div><div style="width:0em;display:inline-block"></div>
<a name="line97"></a><div class="linenumber">97</div><div style="width:0em;display:inline-block"></div>
<a name="line98"></a><div class="linenumber">98</div><div style="width:0em;display:inline-block"></div>/**
<a name="line99"></a><div class="linenumber">99</div><div style="width:0em;display:inline-block"></div>*&nbsp;Custom&nbsp;Error&nbsp;Object&nbsp;for&nbsp;EasyRTC&nbsp;Application&nbsp;Warnings.
<a name="line100"></a><div class="linenumber">100</div><div style="width:0em;display:inline-block"></div>*
<a name="line101"></a><div class="linenumber">101</div><div style="width:0em;display:inline-block"></div>*&nbsp;@extends&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Error
<a name="line102"></a><div class="linenumber">102</div><div style="width:0em;display:inline-block"></div>*&nbsp;@param&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{string}&nbsp;msg&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Text&nbsp;message&nbsp;describing&nbsp;the&nbsp;error.
<a name="line103"></a><div class="linenumber">103</div><div style="width:0em;display:inline-block"></div>*&nbsp;@returns&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{Error}
<a name="line104"></a><div class="linenumber">104</div><div style="width:0em;display:inline-block"></div>*/
<a name="line105"></a><div class="linenumber">105</div><div style="width:0em;display:inline-block"></div>eu.ApplicationWarning&nbsp;=&nbsp;function(msg)&nbsp;{
<a name="line106"></a><div class="linenumber">106</div><div style="width:2em;display:inline-block"></div>eu.ApplicationWarning.super_.call(this,&nbsp;msg,&nbsp;this.constructor);
<a name="line107"></a><div class="linenumber">107</div><div style="width:0em;display:inline-block"></div>};
<a name="line108"></a><div class="linenumber">108</div><div style="width:0em;display:inline-block"></div>util.inherits(eu.ApplicationWarning,&nbsp;g.AbstractError);
<a name="line109"></a><div class="linenumber">109</div><div style="width:0em;display:inline-block"></div>eu.ApplicationWarning.prototype.name&nbsp;=&nbsp;"Application&nbsp;Warning";
<a name="line110"></a><div class="linenumber">110</div><div style="width:0em;display:inline-block"></div>eu.ApplicationWarning.prototype.errorLevel&nbsp;=&nbsp;"warning";
<a name="line111"></a><div class="linenumber">111</div><div style="width:0em;display:inline-block"></div>
<a name="line112"></a><div class="linenumber">112</div><div style="width:0em;display:inline-block"></div>
<a name="line113"></a><div class="linenumber">113</div><div style="width:0em;display:inline-block"></div>/**
<a name="line114"></a><div class="linenumber">114</div><div style="width:0em;display:inline-block"></div>*&nbsp;Custom&nbsp;Error&nbsp;Object&nbsp;for&nbsp;Connection&nbsp;Warnings.
<a name="line115"></a><div class="linenumber">115</div><div style="width:0em;display:inline-block"></div>*
<a name="line116"></a><div class="linenumber">116</div><div style="width:0em;display:inline-block"></div>*&nbsp;@extends&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Error
<a name="line117"></a><div class="linenumber">117</div><div style="width:0em;display:inline-block"></div>*&nbsp;@param&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{string}&nbsp;msg&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Text&nbsp;message&nbsp;describing&nbsp;the&nbsp;error.
<a name="line118"></a><div class="linenumber">118</div><div style="width:0em;display:inline-block"></div>*&nbsp;@returns&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{Error}
<a name="line119"></a><div class="linenumber">119</div><div style="width:0em;display:inline-block"></div>*/
<a name="line120"></a><div class="linenumber">120</div><div style="width:0em;display:inline-block"></div>eu.ConnectionWarning&nbsp;=&nbsp;function(msg)&nbsp;{
<a name="line121"></a><div class="linenumber">121</div><div style="width:2em;display:inline-block"></div>eu.ConnectionWarning.super_.call(this,&nbsp;msg,&nbsp;this.constructor);
<a name="line122"></a><div class="linenumber">122</div><div style="width:0em;display:inline-block"></div>};
<a name="line123"></a><div class="linenumber">123</div><div style="width:0em;display:inline-block"></div>util.inherits(eu.ConnectionWarning,&nbsp;g.AbstractError);
<a name="line124"></a><div class="linenumber">124</div><div style="width:0em;display:inline-block"></div>eu.ConnectionWarning.prototype.name&nbsp;=&nbsp;"Connection&nbsp;Warning";
<a name="line125"></a><div class="linenumber">125</div><div style="width:0em;display:inline-block"></div>eu.ConnectionWarning.prototype.errorLevel&nbsp;=&nbsp;"warning";
<a name="line126"></a><div class="linenumber">126</div><div style="width:0em;display:inline-block"></div>
<a name="line127"></a><div class="linenumber">127</div><div style="width:0em;display:inline-block"></div>
<a name="line128"></a><div class="linenumber">128</div><div style="width:0em;display:inline-block"></div>/**
<a name="line129"></a><div class="linenumber">129</div><div style="width:0em;display:inline-block"></div>*&nbsp;Determines&nbsp;if&nbsp;an&nbsp;Error&nbsp;object&nbsp;is&nbsp;an&nbsp;instance&nbsp;of&nbsp;ApplicationError,&nbsp;ConnectionError,&nbsp;or&nbsp;ServerError.&nbsp;If&nbsp;it&nbsp;is,&nbsp;it&nbsp;will&nbsp;return&nbsp;true.
<a name="line130"></a><div class="linenumber">130</div><div style="width:0em;display:inline-block"></div>*
<a name="line131"></a><div class="linenumber">131</div><div style="width:0em;display:inline-block"></div>*&nbsp;@param&nbsp;&nbsp;&nbsp;{Error}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;err
<a name="line132"></a><div class="linenumber">132</div><div style="width:0em;display:inline-block"></div>*&nbsp;@return&nbsp;&nbsp;{Boolean}
<a name="line133"></a><div class="linenumber">133</div><div style="width:0em;display:inline-block"></div>*/
<a name="line134"></a><div class="linenumber">134</div><div style="width:0em;display:inline-block"></div>eu.isError&nbsp;=&nbsp;function(err)&nbsp;{
<a name="line135"></a><div class="linenumber">135</div><div style="width:2em;display:inline-block"></div>if&nbsp;(err&nbsp;&amp;&amp;&nbsp;((err&nbsp;instanceof&nbsp;eu.ConnectionError)||(err&nbsp;instanceof&nbsp;eu.ApplicationError)||(err&nbsp;instanceof&nbsp;eu.ServerError)||(err&nbsp;instanceof&nbsp;Error)))&nbsp;{
<a name="line136"></a><div class="linenumber">136</div><div style="width:4em;display:inline-block"></div>return&nbsp;true;
<a name="line137"></a><div class="linenumber">137</div><div style="width:2em;display:inline-block"></div>}&nbsp;else&nbsp;{
<a name="line138"></a><div class="linenumber">138</div><div style="width:4em;display:inline-block"></div>return&nbsp;false;
<a name="line139"></a><div class="linenumber">139</div><div style="width:2em;display:inline-block"></div>}
<a name="line140"></a><div class="linenumber">140</div><div style="width:0em;display:inline-block"></div>};
<a name="line141"></a><div class="linenumber">141</div><div style="width:0em;display:inline-block"></div>
<a name="line142"></a><div class="linenumber">142</div><div style="width:0em;display:inline-block"></div>
<a name="line143"></a><div class="linenumber">143</div><div style="width:0em;display:inline-block"></div>/**
<a name="line144"></a><div class="linenumber">144</div><div style="width:0em;display:inline-block"></div>*&nbsp;Determines&nbsp;if&nbsp;an&nbsp;Error&nbsp;object&nbsp;is&nbsp;an&nbsp;instance&nbsp;of&nbsp;ApplicationWarning,&nbsp;ConnectionWarning,&nbsp;or&nbsp;ServerWarning.&nbsp;If&nbsp;it&nbsp;is,&nbsp;it&nbsp;will&nbsp;return&nbsp;true.
<a name="line145"></a><div class="linenumber">145</div><div style="width:0em;display:inline-block"></div>*
<a name="line146"></a><div class="linenumber">146</div><div style="width:0em;display:inline-block"></div>*&nbsp;@param&nbsp;&nbsp;&nbsp;{Error}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;err
<a name="line147"></a><div class="linenumber">147</div><div style="width:0em;display:inline-block"></div>*&nbsp;@return&nbsp;&nbsp;{Boolean}
<a name="line148"></a><div class="linenumber">148</div><div style="width:0em;display:inline-block"></div>*/
<a name="line149"></a><div class="linenumber">149</div><div style="width:0em;display:inline-block"></div>eu.isWarning&nbsp;=&nbsp;function(err)&nbsp;{
<a name="line150"></a><div class="linenumber">150</div><div style="width:2em;display:inline-block"></div>if&nbsp;(err&nbsp;&amp;&amp;&nbsp;((err&nbsp;instanceof&nbsp;eu.ConnectionWarning)||(err&nbsp;instanceof&nbsp;eu.ApplicationWarning)||(err&nbsp;instanceof&nbsp;eu.ServerWarning)))&nbsp;{
<a name="line151"></a><div class="linenumber">151</div><div style="width:4em;display:inline-block"></div>return&nbsp;true;
<a name="line152"></a><div class="linenumber">152</div><div style="width:2em;display:inline-block"></div>}&nbsp;else&nbsp;{
<a name="line153"></a><div class="linenumber">153</div><div style="width:4em;display:inline-block"></div>return&nbsp;false;
<a name="line154"></a><div class="linenumber">154</div><div style="width:2em;display:inline-block"></div>}
<a name="line155"></a><div class="linenumber">155</div><div style="width:0em;display:inline-block"></div>};
<a name="line156"></a><div class="linenumber">156</div><div style="width:0em;display:inline-block"></div>
<a name="line157"></a><div class="linenumber">157</div><div style="width:0em;display:inline-block"></div>
<a name="line158"></a><div class="linenumber">158</div><div style="width:0em;display:inline-block"></div>/**
<a name="line159"></a><div class="linenumber">159</div><div style="width:0em;display:inline-block"></div>*&nbsp;Returns&nbsp;a&nbsp;random&nbsp;available&nbsp;easyrtcid.
<a name="line160"></a><div class="linenumber">160</div><div style="width:0em;display:inline-block"></div>*
<a name="line161"></a><div class="linenumber">161</div><div style="width:0em;display:inline-block"></div>*&nbsp;@return&nbsp;&nbsp;{String}&nbsp;Available&nbsp;easyrtcid.&nbsp;A&nbsp;unique&nbsp;identifier&nbsp;for&nbsp;an&nbsp;EasyRTC&nbsp;connection.
<a name="line162"></a><div class="linenumber">162</div><div style="width:0em;display:inline-block"></div>*/
<a name="line163"></a><div class="linenumber">163</div><div style="width:0em;display:inline-block"></div>eu.getAvailableEasyrtcid&nbsp;=&nbsp;function()&nbsp;{
<a name="line164"></a><div class="linenumber">164</div><div style="width:2em;display:inline-block"></div>var&nbsp;newEasyrtcid&nbsp;=&nbsp;"";
<a name="line165"></a><div class="linenumber">165</div><div style="width:2em;display:inline-block"></div>var&nbsp;easyrtcidExists&nbsp;=&nbsp;false;
<a name="line166"></a><div class="linenumber">166</div><div style="width:0em;display:inline-block"></div>
<a name="line167"></a><div class="linenumber">167</div><div style="width:2em;display:inline-block"></div>do&nbsp;{
<a name="line168"></a><div class="linenumber">168</div><div style="width:4em;display:inline-block"></div>newEasyrtcid&nbsp;=&nbsp;g.randomString();
<a name="line169"></a><div class="linenumber">169</div><div style="width:4em;display:inline-block"></div>easyrtcidExists&nbsp;=&nbsp;false;
<a name="line170"></a><div class="linenumber">170</div><div style="width:4em;display:inline-block"></div>for&nbsp;(var&nbsp;key&nbsp;in&nbsp;e.app)&nbsp;{
<a name="line171"></a><div class="linenumber">171</div><div style="width:6em;display:inline-block"></div>if&nbsp;(e.app[key].connection[newEasyrtcid])&nbsp;{
<a name="line172"></a><div class="linenumber">172</div><div style="width:8em;display:inline-block"></div>easyrtcidExists&nbsp;=&nbsp;true;
<a name="line173"></a><div class="linenumber">173</div><div style="width:8em;display:inline-block"></div>break;
<a name="line174"></a><div class="linenumber">174</div><div style="width:6em;display:inline-block"></div>}
<a name="line175"></a><div class="linenumber">175</div><div style="width:4em;display:inline-block"></div>}
<a name="line176"></a><div class="linenumber">176</div><div style="width:2em;display:inline-block"></div>}&nbsp;while&nbsp;(easyrtcidExists);
<a name="line177"></a><div class="linenumber">177</div><div style="width:0em;display:inline-block"></div>
<a name="line178"></a><div class="linenumber">178</div><div style="width:2em;display:inline-block"></div>return&nbsp;newEasyrtcid;
<a name="line179"></a><div class="linenumber">179</div><div style="width:0em;display:inline-block"></div>};
</code></pre>
</article>
</section>
</div>
		
	</div>
</div>
<footer class="template">
	<div class="wrapper-content">
		<p>Copyright &copy;2016 EasyRTC</p>
	</div>
</footer>
<!-- <script>prettyPrint();</script> -->
<!-- <script src="scripts/linenumber.js"></script> -->
</body>
</html>